<template>
    <div class="app-download-warp">
        <img src="http://img.uuuda.com/udaWeapp2.0/icon/down/app_down_logo.png" class="down-bg"/>
        <img src="https://uuuda.oss-cn-beijing.aliyuncs.com/udaWeapp2.0/icon/down/ios_btn.png" class="down-android" @click="openApp('ios')"/>
        <img src="https://uuuda.oss-cn-beijing.aliyuncs.com/udaWeapp2.0/icon/down/android_btn.png" class="down-android" @click="openApp('and')"/>

        <!--<a href="#" @click="openApp()">-->
            <!--<img src="https://uuuda.oss-cn-beijing.aliyuncs.com/udaWeapp2.0/icon/down/ios_btn.png" class="down-android"/>-->
        <!--</a>-->
        <!--<a href="#" @click="openApp()">-->
            <!--<img src="https://uuuda.oss-cn-beijing.aliyuncs.com/udaWeapp2.0/icon/down/android_btn.png" class="down-android"/>-->
        <!--</a>-->



    </div>
</template>
<script>
let axios = require("axios");
var d = new Date();
var t0 = d.getTime();
var interval = null;
export default {
    data() {
        return {
            isWeiXin:'',
            origin:''
        };
    },

    created() {

        this.isWeiXin = navigator.userAgent.toLowerCase().indexOf('micromessenger') > -1 ? true : false
    },
    mounted(){
        let self = this;
        let query = self.$route.query;
        let origin = query.origin || '';
        self.origin=origin
        self.initOrigin(origin)
    },

    watch:{


    },
    methods: {
        initOrigin:function(origin){
            let self = this;

            axios({
                method: "POST",
                url: "/api/user/setorigin",
                params: {
                    'token': localStorage.getItem('token'),
                    'origin': origin,
                }
            }).then(function(res) {
                let rdata = res.data;
                if(rdata.errno == 200){
                    console.log("更新来源")
                    console.log(rdata)


                }else {
                    self.$dialog.toast({
                        mes: res.data.msg,
                        timeout: 1500
                    });
                }
            });
            },

        openApp:function f(type) {

            // 微信环境
            let self = this

            // self.checkPhone()
            // alert("null")

            let agent = (navigator.userAgent || navigator.vendor || window.opera)

            if (agent != null) {

                // 微信环境
                if(type=='ios'){
                    // 苹果商店链接地址
                    window.location.href = 'https://apps.apple.com/cn/app/id1486538835?sid=15473'
                }else {
                    window.location.href = 'https://uuuda.oss-cn-beijing.aliyuncs.com/udaWeapp2.0/icon/down/app-debug.apk.1'

                }
            }

            }
    },
}

</script>

<style>
    .app-download-warp{
        position: absolute;
        width: 100%;
        height: 100%;
        background: white;
    }
    .down-bg{
        position: relative;
        width: 100%;
    }
    .down-ios{
        position: relative;
        width: 240px;
        height: 48px;
        margin: 0 auto;
        display: block;
    }
    .down-android{
        position: relative; width: 240px;
        height: 48px;
        margin: 24px auto 0 auto;
        display: block;


    }






</style>
